<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>高级网页设计-三级项目</title>
    <style>
        body {
            min-width: 700px;
            max-width: 1200px;
            margin: 0 auto;
        }

        * {
            padding: 0;
            margin: 0;
        }

        li {
            list-style: none;
        }

        .main  a {
            font-size: 16px;
            line-height: 42px;
            font-weight: bold;
            background-color: #03C;
            text-align: center;
            margin: 9px 1%;
            float: left;
            height: 42px;
            width: 18%;
            transition: all 2s;
            border-radius: 4px;
            min-width: 80px;
            color: #FFF;
            letter-spacing: 6px;
            text-decoration: none;

        }

        .main {
            margin: 10px auto;
        }
        .main h2 {
            font-size: 40px;
            line-height: 100px;
            color: #039;
            letter-spacing: 8px;
            text-shadow: 5px 5px 10px #039;
            border-bottom: 2px solid #039;
            margin-bottom: 10px;
            padding-left: 2%;
            transition: all 2s;
            text-align: center;
        }

        .main h2:hover {
            text-shadow: 365px 7px 4px #039;
        }

        .main  a:vistied {
            color: #fff
        }

        .main a:hover {
            color: #eee;
            background-color: #56f;
            border-radius: 18px;
            text-indent: 30px;
            letter-spacing: 20px;
        }


        .tab {
            margin: 5px;
        }

        .t-title {
            height: 33px;
            margin-bottom:15px;

        }

        .t-title span {
            width: 33%;
            height: 33px;
            text-align: center;
            line-height: 45px;
            font-size: 22px;
            float: left;
            color: #56f;
            letter-spacing:2px;
        }

        .t-title .cur {
            background-color: #fff;
            font-weight: bold;
            color: #039;
        }

        .tc {

            padding: 5px;
            display: none;
            min-height:1200px;
        }

        .tc ul {
            overflow: hidden; 
        }

        .show {
            display: block;
    
        }
    </style>
</head>

<body>
    <div class="main">
        <h2>高级网页设计</h2>
        <div class="tab">
            <div class="t-title">
                <span class="cur">三级项目</span>
            </div>
            <div class="tc show">
                <ul>
                    <li><a href="./U/U1-index.html">U净</a></li>
                </ul>
            </div>
            <div class="tc">
                <ul>
                    
                </ul>
            </div>
        </div>
    </div>
    <script>
        var t = document.querySelectorAll(".tab");
        for (var i = 0; i < t.length; i++) {
            tabs(t[i]);
        }

        function tabs(tab) {
            var title = tab.getElementsByClassName("t-title")[0];
            var span = title.getElementsByTagName("span");
            var content = tab.querySelectorAll(".tc");
            console.log(tab, title, span, content);

            for (var i = 0; i < span.length; i++) {
                span[i].onmouseover = function () {
                    for (var j = 0; j < span.length; j++) {
                        content[j].style.display = "none";
                        span[j].index = j;
                        span[j].className = "";
                    }
                    console.log(i);
                    content[this.index].style.display = "block";
                    this.className = "cur";
                } 
            }
        }

        var ul = document.querySelectorAll(".main ul");
        var darr = [1, 2, 3];
        for (let i = 0; i < darr.length; i++) {
            insertContent(ul[i], darr[i]);
        }
        function insertContent(ul, dname) {
            var xmlhttp;
            xmlhttp = new XMLHttpRequest();
            xmlhttp.open("GET", "data/"+dname + ".csv", true);
            xmlhttp.send();
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    result = xmlhttp.responseText;
                    result = result.replace(/[\?\"]/g, "");
                    data = result.split(/\n/);
                    data.forEach((v, i) => {
                        item = v.split(",");
                        let [id, name] = [item[0], item[1]];
                        let li = document.createElement("li");
                        li.innerHTML =
                            `<li><a href="stu/${dname}/${id}/index.html" target="_blank">${name}</a></li>`
                        ul.appendChild(li);
                    })
                }
            }
        }
    </script>
</body>

</html>